package com.zjl.spring.meta;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

/**
 * @Auther: zhuangjl
 * @Date: 2021/11/29 15:48
 */
public class DemoTest {

    public static void main(String[] args) {
        Method[] declaredMethods = Demo.class.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            Annotation[] declaredAnnotations = declaredMethod.getDeclaredAnnotations();
            for (Annotation annotation : declaredAnnotations) {
                if (annotation instanceof Fruit) {
                    Fruit apple = (Fruit) annotation;
                    System.out.println(apple.value());

                } else if (annotation instanceof People) {
                    People people = (People) annotation;
                    System.out.println(people.name() + ":" + people.age());
                }

            }
        }

    }
}
